﻿using System;
using System.Data;
using System.Web.UI;
using DataAccessObject;
using EntityObject;
using SharedLibraries;
using SharedLibraries.Constants;
using ThangNM_LIB.FUNC;

namespace ThangNM
{
    public partial class ShareFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var master = Master as ThangNM.PublicInterface.Home_New;
            try
            {
                if (!IsPostBack)
                {
                    String sLinkByType = FileNameByFunction.Tai_File_;
                    DataSet ds = (new FileDAO()).SelectBy_PK_iFileID(0);
                    if (DataTableEx.DataTable_OK(null, ds, 0))
                    {
                        ds.Tables[0].Columns.Add(new DataColumn("LinkTopicHtml", Type.GetType("System.String")));
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            dr["LinkTopicHtml"] = System.Configuration.ConfigurationManager.AppSettings["HOMEPAGE"] + sLinkByType + RewriteUrl.ConvertToUnSign(dr["sName"].ToString()).ToLower() +"." + dr["PK_iFileID"].ToString() + FileNameByFunction.HTML;
                        }
                        rptFileNew.DataSource = ds.Tables[0];
                        rptFileNew.DataBind();
                    }
                    if (DataTableEx.DataTable_OK(null, ds, 1))
                    {
                        ds.Tables[1].Columns.Add(new DataColumn("LinkTopicHtml", Type.GetType("System.String")));
                        foreach (DataRow dr in ds.Tables[1].Rows)
                        {
                            dr["LinkTopicHtml"] = System.Configuration.ConfigurationManager.AppSettings["HOMEPAGE"] + sLinkByType + RewriteUrl.ConvertToUnSign(dr["sName"].ToString()).ToLower() + "." + dr["PK_iFileID"].ToString() + FileNameByFunction.HTML;
                        }
                        rptFileHot.DataSource = ds.Tables[1];
                        rptFileHot.DataBind();
                    }

                    #region "Meta Tag"//========================================================================================
                    Page.Title = StringEx.TrimEx(TitleSEO.TaiFile + System.Configuration.ConfigurationManager.AppSettings["SLOGAN"]);
                    MetaTagEO _MetaTagEO = new MetaTagEO();
                    _MetaTagEO.PK_iID = 0;
                    _MetaTagEO.sTitle = Page.Title;
                    _MetaTagEO.sDescription = StringEx.TrimEx("chia sẻ file");
                    _MetaTagEO.sTag = "tải file, chia sẻ file, download" + System.Configuration.ConfigurationManager.AppSettings["KEYWORD"];
                    _MetaTagEO.tDateTimeCreate = Convert.ToDateTime("02/02/2015");
                    _MetaTagEO.tDateTimeModify = Convert.ToDateTime("02/02/2015");
                    _MetaTagEO.sCanonical = Request.RawUrl.Substring(1);
                    _MetaTagEO.sShortLink = FileNameByFunction.ShareFile;
                    _MetaTagEO.sLinkImage = "";
                    foreach (var item in Commons.getMetaTag(_MetaTagEO))
                    {
                        Header.Controls.Add(item);
                    }
                    foreach (var item in Commons.getLinkTag(_MetaTagEO))
                    {
                        Header.Controls.Add(item);
                    }
                    #endregion//========================================================================================
                }
            }
            catch (Exception ex)
            {
                if (master != null)
                    master.setNotifications(ConstEx.FunctionSetMsg.ERROR, ex.Message, ex.ToString());
            }
        }
    }
}